#ifndef MOTOR_TASK_H
#define MOTOR_TASK_H
#include "stdint.h"
#include "math.h"
#define TWO_PI 6.283185307179586476925286766559


typedef enum{
    step_0 = 0 ,
    step_1 = 1,
    step_2 = 2,
}motor_state_t;

typedef struct{
    uint32_t count;
    motor_state_t motor_state;
}motor_go_t;

typedef struct{
    float _motor_spd;
    float _motor_ang;
}motor_smo_t;

typedef struct{
    float _dutya;
    float _dutyb;
    float _dutyc;
}motor_duty_abc_t;

typedef struct{
    float _ia;
    float _ib;
    float _ic;
}motor_iabc_t;

typedef struct{
    float _id;
    float _iq;
}motor_idq_t;

typedef struct{
    float _id_ref;
    float _iq_ref;
}motor_idq_ref_t;

typedef struct{
    float _ial;
    float _ibe;
}motor_iab_t;

typedef struct{
    float _ual;
    float _ube;
}motor_uab_t;

typedef struct{
    float OPL_Iq;
    float OPL_Speed;
    float OPL_Time;
    float pmsm_p      ;  
    float pmsm_Rs     ;
    float pmsm_Ld     ;
    float pmsm_Lq     ;
    float pmsm_Ls     ;
    float pmsm_J      ;
    float pmsm_B      ;
    float pmsm_N_max  ;
    float pmsm_Ke     ;
    float pmsm_FluxPM ;
    float pmsm_Kt     ;
    float pmsm_I_rated;
    float pmsm_N_base ;
    float pmsm_F_base ;
    float pmsm_DC     ;
    float pmsm_T_rated;
    float Vmin        ; 
    float Kp_C;
    float ki_C;
    float kp_s;
    float ki_s;
}opl_inf_t;

void _20khz_task(void);
void m_task_2ms(void);
void m_task_10ms(void);
void init_pra(opl_inf_t* init_data);
extern opl_inf_t opl_inf;
extern motor_duty_abc_t motor_duty_abc;
#endif 
